package com.frame.assist.file;

/**
 * @Title: 系统
 * @Description:
 * @Copyright: Copyright (c) 2014
 * @Company:
 * @author 王海锋
 * @CreatedTime:2014-5-10 下午03:43:01
 * @version 1.0
 */

public class FileUtil {

    public  String convertFileSizel(long filesize){
        String strUnit="B";
        int intDivisor=1;
        if(filesize>=1024*1024)
        {
            strUnit = "MB";
            intDivisor=1024*1024;
        }else if(filesize>=1024)
        {
            strUnit = "KB";
            intDivisor=1024;
        }
        if(intDivisor==1)return filesize + "" + strUnit;
        String strAfterComma = "" + 100 * (filesize % intDivisor) / intDivisor ;
        if(strAfterComma=="") strAfterComma=".0";
        return filesize / intDivisor + "." + strAfterComma + "" + strUnit;
    }
    public String convertFileSizel(String filesize){
        return convertFileSizel(Long.parseLong(filesize));
    }
}
